﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Screener.Imaging
{
    public class CellInfo
    {
        public List<short> Indexes { get; set; }
        public int X { get; set; }
        public int Y { get; set; }

        public CellInfo()
        {
            this.Indexes = new List<short>();
        }

        public CellInfo(short index, int x, int y)
        {
            this.Indexes = new List<short>();
            this.Indexes.Add(index);
            this.X = x;
            this.Y = y;
        }

        public void Write(BinaryWriter bw)
        {
            bw.Write((short)this.Indexes.Count);

            foreach (var index in this.Indexes)
            {
                bw.Write(index);
            }

            //bw.Write((byte)((this.X << 4) | (this.Y & 0xF)));

            bw.Write(this.X);
            bw.Write(this.Y);
        }

        public void Read(BinaryReader sr)
        {
            short iCount = sr.ReadInt16();

            for (int i = 0; i < iCount; i++)
            {
                this.Indexes.Add(sr.ReadInt16());
            }

            this.X = sr.ReadInt32();
            this.Y = sr.ReadInt32();
        }

    }
}
